<template>
	<view :class="[primarySize()]">
		<view class="container">
			<view class="bg-white p30">
				<view class="fwb fs34 col3">自我评价</view>
				<textarea class="textarea" v-model="model.content" placeholder="请输入自我评价" maxlength="600" placeholder-class="colb"></textarea>
			</view>
			<view class="plr30 pt50">
			<view class="btn3" @click="bindSubmit()">保存信息</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	var validate = require("../../xilu/validate.js");
	export default {
		data() {
			return {
				
				model:{},
				textNum: 0
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.primaryColor()
			})
		},
		/**
		   * 生命周期函数--监听页面加载
		   */
		onLoad: function (options) {
			
		    this.getOpenerEventChannel().on('dataTransfer', data => {
		      this.model = Object.assign({},data.model); //创建一份浅拷贝, 不影响上一页的值
		      this. textNum = this.model.content.length
		    });
		},
		methods: {
			bindSubmit(event) {
			    let data = this.model;
				var rule = [
					{name: 'content',rules: ['require','length:1,600'],errorMsg: {require: '请填写内容',length:'最多600'}},
				];
				// 是否全部通过，返回Boolean
				if (!validate.check(data, rule)) {
				    uni.showToast({
				        title: validate.getError()[0],
				        icon: 'none'
				    });
				    return;
				}
			    data.module = 'summary';
			    this.$core.post({
			      url: 'xilujob.user/save_module',
			      data: data,
			      success: ret => {
			        this.getOpenerEventChannel().emit('dataTransfer', {model: ret.data.model, complete_percent:ret.data.complete_percent});
			        uni.navigateBack();
			      }
			    });
			  },
		}
	}
</script>

<style lang="scss" scoped>
.textarea{
	width: 100%;
	height: 400rpx;
	padding-top: 30rpx;
	color: #333;
	font-size: 30rpx;
}
</style>
